home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-04 | 1.8 KB | 73 lines | [TEXT/CCL ] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Copyright 1987, 1988, 1989, 1990 by Ruben Kleiman for Apple Computer, Inc.
- ;;; Advanced Technology Group
- ;;;
-
- ;;;
- ;;; KEYBOARD PLAYER:
- ;;; Example of the use of the sound and event code
- ;;; provided in "EVENTS" and "SOUND MANAGER" folders.
- ;;; The number keys are bound to some note. Evaluate this file and depress
- ;;; some number keys to try this out. Try command, shit, and
- ;;; control keys to control sound durations.
-
-
- ;;; This requires the EVENT package.
-
- ;;; To set up some key bindings.
-
-
- (require :event)
-
- (in-package :sound)
-
- (provide :kbd-player)
-
- (defun bind-nkeys ()
- (event:add-eventhook '(play-number-keys) :fast))
-
- (defun play-number-keys ()
- (when (= 3 (%get-word *current-event* 0)) ; when key down
- (let ((c (%get-signed-byte *current-event* 5))
- (d (cond ((command-key-p) 500)
- ((shift-key-p) 1000)
- ((control-key-p) 2000)
- (t 40))))
- (if (and (> c 47)
- (< c 58))
- (sound:do-pitch :d d :f (+ 50 (* (- c 47) 5)))))))
-
- (defvar *pitch* nil)
- (defvar *vol* nil)
-
-
- ;;; could be defconstanted
- (defvar *vol-pix* (/ *screen-height* 255.0))
- (defvar *pitch-pix* (/ *screen-width* 127.0))
-
- (defun play-mouse ()
- (setq *pitch* (truncate (/ (point-h (%get-long ccl::*current-event* 10)) *pitch-pix*)))
- (setq *vol* (truncate (/ (point-v (%get-long ccl::*current-event* 10)) *vol-pix*)))
- (unless (or (> *pitch* 127)
- (> *vol* 255)
- (< *pitch* 0)
- (< *vol* 0))
- (sound::do-pitch :f *pitch* :a *vol*)))
-
-
-
-
- #| TO TRY IT OUT:
-
- To bind number keys to sounds, evaluate:
-
- (bind-nkeys)
-
-
- To cause mouse movement to vary sound, evaluate
-
- (event::add-eventhook '(sound::play-mouse) :fast)
-
- and move mouse around window.
-
- |#